﻿#include "pinyinchar.h"
#include "frminput2019.h"

PinYinChar::PinYinChar(QObject *parent) : QObject(parent)
{
    input = 0;
}

void PinYinChar::setInput(frmInput2019 *input)
{
    this->input = input;
}

void PinYinChar::setBtns(QList<QPushButton *> btns)
{
    this->btns = btns;
}

void PinYinChar::setCharType(quint8 charType, QPushButton *btnChar)
{
    //可自行更改特殊符号,这里可以改成其他输入法使用比如日文韩文俄文等
    input->charType = charType;
    QStringList chars;
    if (charType == 0) {
        //数字+英文
        chars << "0" << "1" << "2" << "3" << "4" << "5" << "6" << "7" << "8" << "9";
        chars << "~" << "@" << "￥" << "-" << "_" << "/" << "\\" << "|" << "\"" << "'";
        chars << "." << "," << ":" << ";" << "?" << "!";
        btnChar->setText("1 / 3");
    } else if (charType == 1) {
        //英文+中文
        chars << "=" << "$" << "%" << "^" << "&&" << "*" << "(" << ")" << "#" << "+";
        chars << "[" << "]" << "{" << "}" << "<" << ">" << "…" << "`" << "“" << "‘";
        chars << "。" << "，" << "：" << "；" << "？" << "！";
        btnChar->setText("2 / 3");
    } else {
        //中文+其他
        chars << "＞" << "【" << "】" << "｛" << "｝" << "《" << "》" << "（" << "）" << "＜";
        chars << "↑" << "↓" << "←" << "→" << "^_^" << "*_*" << "^▽^" << "∩_∩" << "√" << "×";
        chars << "﹍" << "|" << "△" << "☆" << "±" << "￥";
        btnChar->setText("3 / 3");
    }

    //格式 btn0 - btn25
    foreach (QPushButton *btn, btns) {
        QString objName = btn->objectName();
        if (objName.length() <= 5) {
            int index = objName.mid(3, objName.length() - 3).toInt();
            btn->setText(chars.at(index));
        }
    }
}
